package com.gxa.saas.portal.mapper;


import com.gxa.saas.core.vo.GoodsVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Auther: pengxtao
 * @Date: 2022/7/21下午8:57
 * 查询商品数据
 */
@Mapper
public interface AppInfoMapper {

	@Select("SELECT DISTINCT pr.sales AS sales,pr.pr_id AS prId,pr.pr_price AS prPrice,pr.pr_name AS prName,(SELECT picture.picture_name FROM picture WHERE picture.pro_id = pr.id LIMIT 1 ) AS picture,(SELECT first_classify.first_name AS firstName FROM first_classify,second_classify WHERE second_classify.se_name = (SELECT sc.se_name FROM second_classify sc, product_classify pc WHERE pr.id = pc.product_id AND sc.id = pc.classify_id  LIMIT 1) AND first_classify.id = second_classify.fc_id) AS firstName FROM product pr ,first_classify fc where pr.g_status = 1")
	public List<GoodsVo> selectGoods();

	@Select("SELECT first_classify.first_name AS firstName FROM first_classify,second_classify\n" +
			"WHERE second_classify.se_name = (SELECT sc.se_name FROM product pr,second_classify sc, product_classify pc\n" +
			" WHERE pr.pr_id = pc.product_id AND sc.id = pc.classify_id AND pr.pr_id=#{prId} LIMIT 1) AND first_classify.id = second_classify.fc_id")
	public String selectGoodsFirstClassify(@Param("prId") String prId);

	@Select("SELECT DISTINCT pr.sales AS sales,pr.pr_id AS prId,pr.pr_price AS prPrice,pr.pr_name AS prName,(SELECT picture.picture_name FROM picture WHERE picture.pro_id = pr.id LIMIT 1 ) AS picture,(SELECT first_classify.first_name AS firstName FROM first_classify,second_classify WHERE second_classify.se_name = (SELECT sc.se_name FROM second_classify sc, product_classify pc WHERE pr.id = pc.product_id AND sc.id = pc.classify_id  LIMIT 1) AND first_classify.id = second_classify.fc_id) AS firstName FROM product pr ,first_classify fc where pr.g_status = 1 AND pr.pr_id=#{prId}\n")
	public List<GoodsVo> NewselectGoods(@Param("prId") String prId);


	
}
